-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(upgrade): introduce tracing as an optional unstable feature #3326
Conversation
57c5827
to
25f10dc
Compare
This change allow users to opt out of tracing via the `tracing` crate by adding tracing as an optional feature. This change is part of the effort, outlined in hyperium#2874, to reach hyper 1.0. Closes hyperium#3319 BREAKING CHANGES: tracing is disabled by default and requires users to opt in to revert to previous behavior.
Thanks for taking this on! We need to make it unstable similar to the FFI feature, with a check in Separately, one possible way I think this could be done is making an internal module with trace and debug macros, and inside those out the cfg checks. It's not a big deal, it just might be easier. |
Thanks for the feedback. An internal module would definitely be a cleaner approach, and would help with unused variable warnings. I'll get started on that. |
Introduce several macros that act as wrappers around the `tracing` module's macros to allow for more concise syntax for conditional compilation of `tracing` macro calls. As `tracing` is unstable, the new `trace` module will facilitate transitioning `tracing` to an optional feature, as outlined in hyperium#2874 and hyperium#3326. BREAKING CHANGES: Integration of macros requires the replacement of uses of `trace` macros.
…al trace module Refactor code to utilize tracing macros from the new `trace` module and fix breaking changes described in commit aba2a35. Part of the effort to transition `tracing` to an unstable feature hyperium#3326 #hyperium#2874.
…ompilation. Usage of variables passed into the `trace` module is dependent on whether the `tracing` feature is enabled, thus producing a compiler warning when `tracing` is disabled. Prefix potentially unused variables with an underscore to indicate that this is intentional.
Add a `rustc` configuration flag (`hyper_unstable_tracing`) that must be passed to the compiler when using the `tracing` feature. Throw a compiler error if `tracing` is enabled without the flag. Part of the effort to transtition `tracing` to an unstable dependecy. See hyperium#3326 and hyperium#2874.
…sage Add curly braces around a call to the `trace::debug` macro within a `map_err` anonymous function. The change is necessary to convert the function from an expression to a block to allow for conditional compilation.
…ature list Document `trace` and add new features to the documentation feature list. Modify `package.metadata.docs.rs` in `Cargo.toml` to include `tracing` to list of `features` and `--cfg hyper_unstable_tracing` to the list of `rustdoc-args`.
I think a quick overview of the changes I made might be helpful in reviewing the PR, so here goes:
macro_rules! debug_span {
($($arg:tt)*) => {
#[cfg(feature = "tracing")]
{
#[cfg(not(hyper_unstable_tracing))]
compile_error!(
"\
The `tracing` feature is unstable, and requires the \
`RUSTFLAGS='--cfg hyper_unstable_tracing'` environment variable to be set.\
"
);
let span = tracing::debug_span!($($arg)+);
let _ = span.enter();
}
}
}
I think that covers it. Please let me know what you think and if there are any improvements I can make. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much, the work is very thorough, and your write up is spectacular.
…arly Span macros in the `trace` module drop the `Span` early, making them useless. The fix changes their implementation such that they return the RAII guard, so the span is consumed and the guard is not dropped.
Remove an extraneous cfg attribute that was added erroneously in a previous commit.
Remove `trace` documetationfrom `trace.rs`. Add unstable section to `lib.rs` detailing unstable features. Add information about `tracing` and `ffi` to unstable features section.
Change condition for when compile error is thrown in the `trace` module, as the module is compiled even when tracing is disabled. Throw when `unstable_hyper_tracing` is not specified while tracing flag is enabled. Removed semi-colons after `Span.entered()` to ensure RAII guard is returned.
Log errors as a field rather than part of a formatted string.
Similar to ffi, the feature job will skip tracing as it is unstable and requires a cfg flag to compile without an error. Once hyperium#3326 is merged, subsequent PRs will fail the feature CI job without this change.
All the things look good to me, thanks! Good job! You could include the change to the CI features check in this PR, so that it merges with the relevant code. Also, looks like there's merge conflicts. |
Similar to ffi, the feature job will skip tracing as it is unstable and requires a cfg flag to compile without an error. Once hyperium#3326 is merged, subsequent PRs will fail the feature CI job without this change.
Thank you. I moved the CI change here. It should be good to go. |
…erium#3326) This change allow users to opt out of tracing via the `tracing` crate by adding tracing as an optional feature. This change is part of the effort, outlined in hyperium#2874, to reach hyper 1.0. - Introduce several macros that act as wrappers around the `tracing` module's macros to allow for more concise syntax for conditional compilation of `tracing` macro calls. As `tracing` is unstable, the new `trace` module will facilitate transitioning `tracing` to an optional feature, as outlined in hyperium#2874 and hyperium#3326. - Refactor code to utilize tracing macros from the new `trace` module. - Add a `rustc` configuration flag (`hyper_unstable_tracing`) that must be passed to the compiler when using the `tracing` feature. Throw a compiler error if `tracing` is enabled without the flag. Part of the effort to transtition `tracing` to an unstable dependecy. See hyperium#3326 and hyperium#2874. - Modify `package.metadata.docs.rs` in `Cargo.toml` to include `tracing` to list of `features` and `--cfg hyper_unstable_tracing` to the list of `rustdoc-args`. - Add unstable section to `lib.rs` detailing unstable features. Add information about `tracing` and `ffi` to unstable features section. - Log errors as a field rather than part of a formatted string. Closes hyperium#3319 BREAKING CHANGES: tracing is disabled by default and requires users to opt in to an unstable feature to revert to previous behavior.
…erium#3326) This change allow users to opt out of tracing via the `tracing` crate by adding tracing as an optional feature. This change is part of the effort, outlined in hyperium#2874, to reach hyper 1.0. - Introduce several macros that act as wrappers around the `tracing` module's macros to allow for more concise syntax for conditional compilation of `tracing` macro calls. As `tracing` is unstable, the new `trace` module will facilitate transitioning `tracing` to an optional feature, as outlined in hyperium#2874 and hyperium#3326. - Refactor code to utilize tracing macros from the new `trace` module. - Add a `rustc` configuration flag (`hyper_unstable_tracing`) that must be passed to the compiler when using the `tracing` feature. Throw a compiler error if `tracing` is enabled without the flag. Part of the effort to transtition `tracing` to an unstable dependecy. See hyperium#3326 and hyperium#2874. - Modify `package.metadata.docs.rs` in `Cargo.toml` to include `tracing` to list of `features` and `--cfg hyper_unstable_tracing` to the list of `rustdoc-args`. - Add unstable section to `lib.rs` detailing unstable features. Add information about `tracing` and `ffi` to unstable features section. - Log errors as a field rather than part of a formatted string. Closes hyperium#3319 BREAKING CHANGES: tracing is disabled by default and requires users to opt in to an unstable feature to revert to previous behavior. Signed-off-by: Sven Pfennig <[email protected]>
This change allow users to opt out of tracing via the
tracing
crate by adding tracing as an optional feature. This change is part of the effort, outlined in #2874, to reach hyper 1.0.Closes #3319
BREAKING CHANGES: tracing is disabled by default and requires users to opt in to revert to previous behavior.